import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MachineTypeVO, MachineTypeForm, MachineTypeQuery } from '@/api/agriculture/machineType/types';

/**
 * 查询机械类别列表
 * @param query
 * @returns {*}
 */

export const listMachineType = (query?: MachineTypeQuery): AxiosPromise<MachineTypeVO[]> => {
  return request({
    url: '/agriculture/machineType/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询机械类别详细
 * @param machineTypeId
 */
export const getMachineType = (machineTypeId: string | number): AxiosPromise<MachineTypeVO> => {
  return request({
    url: '/agriculture/machineType/' + machineTypeId,
    method: 'get'
  });
};

/**
 * 新增机械类别
 * @param data
 */
export const addMachineType = (data: MachineTypeForm) => {
  return request({
    url: '/agriculture/machineType',
    method: 'post',
    data: data
  });
};

/**
 * 修改机械类别
 * @param data
 */
export const updateMachineType = (data: MachineTypeForm) => {
  return request({
    url: '/agriculture/machineType',
    method: 'put',
    data: data
  });
};

/**
 * 删除机械类别
 * @param machineTypeId
 */
export const delMachineType = (machineTypeId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/machineType/' + machineTypeId,
    method: 'delete'
  });
};
